﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Lib.Helper;
using MSIACCSL2.ViewModels;
using WcfService1.DTO;

namespace MSIACCSL2.Views.COA
{
    public partial class Add : ChildWindow
    {
        public COAViewModel ViewModel
        {
            get { return (COAViewModel) this.DataContext; }
        }
        public Add()
        {
            InitializeComponent();
            EventAggregator.RegisterMessage("ShowDetailSaldoHutang",(x,y)=>
                                                                        {
                                                                            var detail = new DetailSaldoHutang();
                                                                            detail.Show();
                                                                            ((SaldoHutangViewModel) detail.DataContext)
                                                                                .SaldoAwalHutangs = (ObservableCollection<SaldoAwalHutang>) y;

                                                                            ((SaldoHutangViewModel) detail.DataContext)
                                                                                ._coa = (CoaDTO) x;
                                                                        });
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
          
        }

      

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void btnSADebit_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            EventAggregator.RegisterMessage("SaveSaldoAwalPiutangFinished", (x) =>
            {
                COAViewModel.COA.SaldoAwalDebit = (decimal)x;
            });

            ViewModel.GetSaldoAwalPiutang();
        }

        private void btnSAKredit_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            EventAggregator.RegisterMessage("SaveSaldoAwalHutangFinished", (x) =>
                                                                               {

                                                                                   COAViewModel.COA.SaldoAwalKredit = (decimal) x;
                                                                               });

             ViewModel.GetSaldoAwalHutang();
        	
        }
    }
}

